package com.cxrj.zhsq.parkingLotManage.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cxrj.zhsq.parkingLotManage.entity.PropertyParkingSpace;
import com.cxrj.zhsq.parkingLotManage.service.ParkingSpaceService;

@RestController
public class ParkingSpaceController {
	@Resource
	private ParkingSpaceService parkingSpaceService;
	
	/**
	 * 分页查询
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("selectParkingSpacePage")
	public Map<String, Object> selectParkingSpacePage(HttpServletRequest request,HttpServletResponse response){
		return parkingSpaceService.selectParkingSpacePage(request,response);
	}
	
	/**
	 * 删除
	 * @param id
	 * @param request
	 * @return
	 */
	@RequestMapping("delParkingSpace")
	public Map<String, Object> delParkingSpace(String id,HttpServletRequest request){
		return parkingSpaceService.deleteParkingSpace(id,request);
	}
	
	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@RequestMapping("delParkingSpaceByIds")
	public Map<String, Object > deleteByIds(@RequestParam("ids[]") String[] ids){
		return parkingSpaceService.deleteByIds(ids);
	}
	
	/**
	 * 批量添加
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("insertParkingSpaceList")
	public Map<String, Object> insertParkingSpaceList(HttpServletRequest request,HttpServletResponse response){
		return parkingSpaceService.insertParkingSpaceList(request,response);
	}
	
	/**
	 * 根据Id查询
	 * @param id
	 * @param request
	 * @return
	 */
	@RequestMapping("selectParkingSpaceById")
	public Map<String, Object> selectParkingSpaceById(String id,HttpServletRequest request){
		return parkingSpaceService.selectParkingSpaceById(id,request);
	}
	
	/**
	 * 判断编号是否重复
	 * @param number
	 * @param request
	 * @return
	 */
	@RequestMapping("checkingParkingSpaceNumber")
	public Map<String, Object> checkingParkingSpaceNumber(String number,HttpServletRequest request){
		return parkingSpaceService.checkingParkingSpaceNumber(number,request);
	}
	
	/**
	 * 添加
	 * @param parkingSpace
	 * @param request
	 * @return
	 */
	@RequestMapping("insertParkingSpace")
	public Map<String, Object> insertParkingSpace(PropertyParkingSpace parkingSpace,HttpServletRequest request){
		return parkingSpaceService.insertParkingSpace(parkingSpace,request);
	}
	
	/**
	 * 修改
	 * @param parkingSpace
	 * @param request
	 * @return
	 */
	@RequestMapping("updateParkingSpace")
	public Map<String, Object> updateParkingSpace(PropertyParkingSpace parkingSpace,HttpServletRequest request){
		return parkingSpaceService.updateParkingSpace(parkingSpace,request);
	}
	
	/**
	 * 车位出售、出租
	 * @param parkingSpace
	 * @param request
	 * @return
	 */
	@RequestMapping("updateParkingSpaceState")
	public Map<String, Object> updateParkingSpaceState(PropertyParkingSpace parkingSpace,HttpServletRequest request)throws Exception{
		return parkingSpaceService.updateParkingSpaceState(parkingSpace,request);
	}
}
